<?php

namespace App\Http\Requests;

use App\Http\Requests\Request;

class CreatePermissionRequest extends Request
{
    /**
     * Determine if the user is authorized to make this request.
     *
     * @return bool
     */
    public function authorize()
    {
        return true;
    }

    /**
     * Get the validation rules that apply to the request.
     *
     * @return array
     */
    public function rules()
    {
        return [
            'name' => 'required|unique:permissions,name',
            'display_name' => 'required',
            'pid' => 'required',
        ];
    }

    public function attributes()
    {
        return [
            'name' => '权限路由',
            'display_name' => '权限名称',
            'description' => '权限概述',
            'pid' => '父级ID',
        ];
    }

    /**
     * Get the validation messages that apply to the request.
     *
     * @return array
     */
    public function messages()
    {
        return [
            'name.required' => '请填写权限路由',
            'name.unique' => '权限路由已存在，请重新输入',
            'display_name.required' => '请填写权限名称',
            'pid.required' => '请选择权限组',
        ];
    }

}
